/*
* $Id: DayDraw.cpp 67 2010-03-18 18:36:53Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "DayDraw.h"

CDayDraw::CDayDraw(int day)
: m_nDay(day), m_bSel(false){}
CDayDraw::~CDayDraw(){}

void CDayDraw::SetBeginPoint(CPoint point){
	m_rect.MoveToXY(point);
}
CRect CDayDraw::GetRect(){
	return m_rect;
}
void CDayDraw::SetSel(bool bSel){
	m_bSel = bSel;
}
bool CDayDraw::IsSel(){
	return m_bSel;
}

void CDayDraw::Paint(CDC* dc){
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	HGDIOBJ oldPen = dc->SelectObject(pen);
	CBrush brush;
	brush.CreateSolidBrush(RGB(0,0,255));
	HGDIOBJ oldBrush = NULL;
	if(m_bSel){
		oldBrush = dc->SelectObject(brush);
		dc->SetTextColor(RGB(255, 255, 255));
	}
	dc->Rectangle(m_rect.left, m_rect.top, m_rect.right + 1, m_rect.bottom + 1);
	dc->SetBkMode(TRANSPARENT);
	dc->DrawText(CConvertFunction::ConvertFromInt(m_nDay).c_str(), m_rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
	dc->SelectObject(oldPen);
	if(oldBrush){
		dc->SelectObject(oldBrush);
		dc->SetTextColor(RGB(0, 0, 0));
	}
	brush.DeleteObject();
	pen.DeleteObject();
}

void CDayDraw::SetSize(CSize size){
	m_rect.bottom = m_rect.top + size.cy;
	m_rect.right = m_rect.left + size.cx;
}